package com.epam.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public enum ConfigurationManager {
	INSTANCE;

	private static final Logger LOG = Logger.getLogger(ConfigurationManager.class);
	
	//DATABASE CONFIG
	public static final String FILE_NAME = "properties.properties";
	public static final String DATABASE_URL = "DATABASE_URL";
	public static final String DATABASE_LOGIN = "DATABASE_LOGIN";
	public static final String DATABASE_PASSWORD = "DATABASE_PASSWORD";
	public static final String DATABASE_DRIVER_NAME = "DATABASE_DRIVER_NAME";
	public static final String CONNECTIONS_NUMBER = "CONNECTIONS_NUMBER";
	
	//PAGES
	public static final String LOGIN_PAGE = "LOGIN_PAGE";
	public static final String SUCCESS_AUTHORIZATION = "SUCCESS_AUTHORIZATION";
	public static final String ADMIN_PAGE = "ADMIN_PAGE";
	public static final String HOTEL_MANAGER = "HOTEL_MANAGER";
	public static final String TOUR_MANAGER = "TOUR_MANAGER";
	public static final String USER_MANAGER = "USER_MANAGER";
	public static final String SHOPPING_CART = "SHOPPING_CART";
	public static final String TOUR_LIST = "TOUR_LIST";
	public static final String PURCHASES = "PURCHASES";
	public static final String PURCHASE_ERROR = "PURCHASE_ERROR";
	public static final String PURCHASE_SUCCESSFUL = "PURCHASE_SUCCESSFUL";
	public static final String OPERATION_SUCCESSFUL = "OPERATION_SUCCESSFUL";
	
	//MISCELLANEOUS
	public static final String NUMBER_OF_RECORDS_ON_PAGE = "NUMBER_OF_RECORDS_ON_PAGE";
	
	
	private static Properties prop = new Properties();
	private static InputStream is = ConfigurationManager.class.getClassLoader()
			.getResourceAsStream(FILE_NAME);
	
	
	public static String getConfig(String key) { 
		try {
			prop.load(is);
		} catch (IOException e) {
			LOG.error(e);
		}
		return (String) prop.getProperty(key);
	}

}
